package  com.pcbly.web.business.publicinfo;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.publicinfo.MessageReceiverDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.publicinfo.MessageReceiverBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class MessageReceiverServiceImp extends BaseServiceImp<MessageReceiverBean> implements MessageReceiverService {
	 public MessageReceiverServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private MessageReceiverDao messageReceiverDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setMessageReceiverDao(MessageReceiverDao messageReceiverDao) {
		this.messageReceiverDao = messageReceiverDao;
	}
	
	@Override
	public MessageReceiverBean getMessageReceiverBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return messageReceiverDao.get(MessageReceiverBean.class,id);
	}
	
	@Override
	public void removeMessageReceiverBeanById(String id) throws Exception{
		messageReceiverDao.removeMessageReceiverBeanById(id);
	}
	
	@Override
	public void removeMessageReceiverBeanByIds(String ids) throws Exception{
		messageReceiverDao.removeMessageReceiverBeanByIds(ids);
	}
	
	
	@Override
	public MessageReceiverBean saveMessageReceiverBean(MessageReceiverBean publicinfo) throws Exception{
		return messageReceiverDao.saveMessageReceiverBean(publicinfo);
	}
	
	@Override
	public MessageReceiverBean updateMessageReceiverBean(MessageReceiverBean publicinfo) throws Exception{
		messageReceiverDao.saveObject( publicinfo);
		return publicinfo;
	}
	public Page<MessageReceiverBean>  findMessageReceiverBeanByCond(MessageReceiverBean bean,
			Page<MessageReceiverBean> page, String orderByName, boolean asc)
			throws Exception{
		return messageReceiverDao.findMessageReceiverBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findMessageReceiverBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findMessageReceiverBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = messageReceiverDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findMessageReceiverBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = messageReceiverDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveMessageReceiverBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		messageReceiverDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasMessageReceiverBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return messageReceiverDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
